<?php 
App::import('Vendor','tcpdf/tcpdf');

$pdf = new TCPDF(); 
$textfont = 'freesans';

$pdf->SetCreator(PDF_CREATOR);
$pdf->SetTitle('RELATÓRIO DE ATENDIMENTO');

$pdf->setHeaderFont(Array(PDF_FONT_NAME_MAIN, '', PDF_FONT_SIZE_MAIN));
$pdf->setFooterFont(Array(PDF_FONT_NAME_DATA, '', PDF_FONT_SIZE_DATA));

$pdf->SetDefaultMonospacedFont(PDF_FONT_MONOSPACED);

$pdf->SetMargins(PDF_MARGIN_LEFT, PDF_MARGIN_TOP, PDF_MARGIN_RIGHT);
$pdf->SetHeaderMargin(PDF_MARGIN_HEADER);
$pdf->SetFooterMargin(PDF_MARGIN_FOOTER);
$pdf->SetAutoPageBreak(TRUE, PDF_MARGIN_BOTTOM);

$pdf->setImageScale(PDF_IMAGE_SCALE_RATIO); 

$pdf->AddPage(); 
$pdf->Image('img/logo.jpg', 10, 5, 0, 0);

$pdf->writeHTML('<br><p align="center"><b><font size="18">RELATÓRIO DE ATENDIMENTO</font></b></p><br><br>', false, false, true, false, '');

$topo = 
'<table cellpadding="3" cellspacing="0" border="1px">
	<tr bgcolor="#b8b8b8">
    	<th align="center" width="25%"><b>DATA</b></th>
    	<th align="center" width="25%"><b>TIPO OS</b></th>
    	<th align="center" width="50%"><b>OS ABERTAS/ATENDIDAS</b></th>
	</tr>
</table>';
$pdf->writeHTML($topo, false, false, true, false, '');
	$i = 0;
	foreach ($ordemservicos as $ordemservico) {
$linhas = ''.
'<table cellpadding="3" cellspacing="0" border="1px">
	<tr>
		<td align="center" width="25%">'.$ordemservico['data'].'</td>
		<td align="center" width="25%">'.$ordemservico['tipo'].'</td>
		<td align="center" width="50%">'.$ordemservico['quantidade'].'</td>
	</tr>
</table>';
		$pdf->writeHTML($linhas, false, false, true, false, '');
	} 

$pdf->Output('relatorio_de_atendimento.pdf', 'I');
?>